package com.sky.yipinyoufujava.mapper;


import com.sky.yipinyoufujava.pojo.from.ServiceDateFrom;
import com.sky.yipinyoufujava.pojo.service.ServiceDate;
import com.sky.yipinyoufujava.pojo.service.ServiceTime;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface ServiceDateMapper {
    @Select("SELECT id,shopsId,`value`,pageValue,status,createdTime,updatedTime FROM ServiceDate WHERE shopsId = #{shopsId} AND `value` >= #{today}")
    List<ServiceDate> getServiceDate(@Param("shopsId") Object shopsId,@Param("today")  LocalDate today);

    @Select("SELECT * FROM ServiceTime WHERE serviceId = #{serviceId} AND `value` >= #{timeNow};")
    List<ServiceTime> getServiceTime(@Param("serviceId") Object serviceId,@Param("timeNow") String timeNow);


        @Select("SELECT id,ServiceDate.shopsId,`value`,PageValue,status,createdTime,updatedTime FROM ServiceDate WHERE shopsId = #{shopsId} AND `value`=#{date};")
    ServiceDate getShopsServiceDate(ServiceDateFrom serviceDateFrom);

    @Select("select * from ServiceTime where serviceId = #{id}")
    List<ServiceTime> getShopsServiceTime(Integer id);

    void addServiceTime(@Param("serviceDateFrom") ServiceDateFrom serviceDateFrom,@Param("timeIntervals") List<String> timeIntervals);

    @Select("SELECT id FROM ServiceDate WHERE `value`=#{date} AND shopsId=#{shopsId}")
    Integer queryDateId(@Param("date") String date,@Param("shopsId") String shopsId);



    @Insert("INSERT INTO ServiceDate(shopsId,`value`) VALUES(#{shopsId},#{date})")
    void addServiceDate(ServiceDateFrom serviceDateFrom);
}
